package com.chen.webuser.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chen.webuser.entity.WebUser;
import com.chen.webuser.entity.WebUserInfo;
import com.chen.webuser.mapper.WebUserMapper;
import com.chen.webuser.service.WebUserInfoService;
import com.chen.webuser.service.WebUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chen
 * @since 2025-10-19
 */
@Service
public class WebUserServiceImpl extends ServiceImpl<WebUserMapper, WebUser> implements WebUserService {
     @Autowired
     private WebUserMapper webUserMapper;

     @Autowired
     private WebUserInfoService webUserInfoService;
    /**
     * 根据用户uid查询用户信息
     * @param userIdList
     * @return
     */
    @Override
    public List<WebUser> selectByIds(List<Integer> userIdList) {
        List<WebUser> webUsers = webUserMapper.selectBatchIds(userIdList);
        //根据 uid查询, webUserinfo
      List<WebUserInfo> webUserInfoList=  webUserInfoService.selectByUid(userIdList);
      // 封装webUsers的webUserInfo
        for (WebUser webUser : webUsers) {
            for (WebUserInfo webUserInfo : webUserInfoList) {
                if (webUser.getUid().equals(webUserInfo.getUid())) {
                    webUser.setWebUserInfo(webUserInfo);
                }
            }
        }
        return webUsers;
    }
}
